/**
 * Search-box.ai
 * Author: Simon-Pierre Boucher
 * Contact: contact@spboucher.ai
 * File: apps/web/app/r/[id]/page.tsx
 * Description: Research session page — server wrapper around the live client view.
 */

import { notFound } from "next/navigation";
import { sessions } from "@search-box/db";
import { ensureMigrated } from "@/lib/runner";
import { SessionView } from "@/components/SessionView";

export const dynamic = "force-dynamic";

export default async function SessionPage({ params }: { params: Promise<{ id: string }> }) {
  await ensureMigrated();
  const { id } = await params;
  const session = await sessions.get(id);
  if (!session) notFound();

  return <SessionView id={id} question={session.question} initialStatus={session.status} />;
}
